// app.js
import store from './store/index.js'
import { request } from "request/index.js";

App({
  store,
  onLaunch() {
    request({
      url: 'user/refreshToken',
      method: "GET"
    })
    .then(result=>{
      console.log(result)
      if(result.data.code === 10002){
        wx.removeStorageSync('userinfo')
        wx.removeStorageSync('token')
        wx.showToast({
          title: '请先登录',
          icon: 'error',
          duration: 2000,
        });
          
      }
      else{
      wx.setStorageSync('token', result.data.data.token)
      }
    })
  },
  globalData: {
    userInfo: null
  }
})
